#ifndef MAINWIDGET_H
#define MAINWIDGET_H

#include <QWidget>
#include <QMouseEvent>
#include "sina/sinawidget.h"
#include "rss/rssreader.h"
#include "renren/renrenwidget.h"
#include "loginwidget.h"


namespace Ui {
    class MainWidget;
}

class MainWidget : public QWidget
{
    Q_OBJECT

public:
    explicit MainWidget(QWidget *parent = 0);
    ~MainWidget();
private:
    enum Position {
        Left = 0,
        Up = 1
    };
    enum Client {
        None   = 0,
        Login  = 1,
        RenRen = 2,
        Sina   = 3,
        Rss    = 4
    };
protected:
    void mousePressEvent(QMouseEvent *);
    QByteArray toQByteArray(int);
    void loadClient(Client client);
    void removeCurrentClient();
    void changeSelecedPixmap(int,int);
    int currentSelected;

private:
    Ui::MainWidget *ui;
    Client currentClient;
    SinaWidget *pSinaWidget;
    LoginWidget *pLoginWidget;
    RssReader *pRssReader;
    RenrenWidget *pRenrenWidget;
    QList<Client> clientList;
    QPixmap renrenPhoto;
    QPixmap sinaPhoto;
    const static int widget_width  = 80;
    const static int widget_height = 80;
    const static int label_width   = 60;
    const static int label_height  = 60;
    const static int distance      = 10;

signals:
    void clicked(Position pos,int index);
    void sendSignalToSina(int index);
    void sendSignalToRenren(int index);
    void forward_to_otheClientSignal(QString str);

private slots:
    void response(Position pos ,int index);
    void loginSuccessed(Client client);
    void forwardToOtherClientSlot(QString);

protected:
    void closeEvent(QCloseEvent *);
};

#endif // MAINWIDGET_H
